package com.dhecp.project.system.controller;

import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.project.system.domain.SysApiLog;
import com.dhecp.project.system.service.SysApiLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/system/apilog")
public class SysApiLogController extends BaseController {

    private String prefix = "system/apilog";

    @Autowired
    private SysApiLogService sysApiLogService;

    @RequiresPermissions("system:apilog:view")
    @GetMapping()
    public String apilog()
    {
        return prefix + "/apilog";
    }

    @RequiresPermissions("system:apilog:list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<SysApiLog> list = sysApiLogService.queryApiLogList(params);
        return getDataTable(list);
    }

    /**
     * API调度日志详情
     */
    @RequiresPermissions("system:apilog:view")
    @GetMapping("/detail/{logId}")
    public String detail(@PathVariable("logId") int logId, ModelMap mmap)
    {
        mmap.put("apilog", sysApiLogService.queryApiLogById(logId));
        return prefix + "/apilog_detail";
    }

}
